/*
 * @Author: zhuwenzhi
 * @Date: 2024-06-19 21:14:42
 * @LastEditTime: 2024-06-19 22:01:25
 * @LastEditors: zhuwenzhi
 * @FilePath: /dva-quickstart/src/routes/Products.js
 * @Description: 
 */
import React from 'react';
import { connect } from 'dva';
import ProductList from '../components/ProductList';

const Products = ({ dispatch, products }) => {

  function handleDelete(id) {
    dispatch({
      type: 'products/delete',
      payload: id,
    });
  }

  return (
    <div style={{margin: '20px'}} >
      <h2>List of Products</h2>
      <ProductList onDelete={handleDelete} products={products} />
    </div>
  );
};

// export default Products;
export default connect(({ products }) => ({
  products,
}))(Products);
